import service from "../axios/index";

export function request(options) {
    options.method = options.method || 'get'; // 如果是get请求的话，则将data中的数据转移到params中
    if (options.method.toLowerCase() === 'get') {
        options.params = options.data;
    }

    return service(options)
}

['get', 'post'].forEach((item) => {
    request[item] = (url, data, options) => {
        return request({
            method: item,
            url,
            data,
            ...options
        })
    }
});

export default request